{% extends "base.html" %}
{% block title %}{{ dish.name }}{% endblock %}
{% block head %}{{ dish.name }} at {{ dish.place }}{% endblock %}
{% block content %}
{% if avg_rating %}
	{% with dish.review_set.count as total %}
		Avg Rating: {{ avg_rating }} stars based on {{ total }} reviev{{ total|pluralize }}
	{% endwith %}
{% else %}
	No reviews yet. Write one!
{% endif %}
<p>
<a href="/submit/review/dish/{{ dish.id }}/">add review</a> |
<a href="/submit/photo/dish/{{ dish.id }}/">add photo</a>
<p>
{% if dish.dishimage_set.all %}
	Photos
	<ul>
	{% for img in dish.dishimage_set.all %}
		<li>
			<a href="{{ img.display.url }}"><img src="{{ img.thumbnail.url }}" /></a><br>posted by {{ img.user }} on {{ img.created_date }}
		</li>
	{% endfor %}
	</ul>
{% endif %}

{% if dish.review_set.all %}
	Reviews
	<ul>
	{% for rev in dish.review_set.all %}
		<li>
		{{ rev.rating }} stars -
		"{{ rev.text }}"<br>
		posted by {{ rev.user }} on {{ rev.created_date }}
		</li>
	{% endfor %}
	</ul>
{% else %}
	No reviews yet.
{% endif %}

{% endblock %}